﻿<%@ Register TagPrefix="dammela" Namespace="whole" Assembly = "dammela" %>
<%@ Page Language="C#" Description="Homepage" trace="true" debug="true" EnableViewState="false"%>
<%@ Import Namespace="dammelau"%>
<%@ Import Namespace="System.Xml"%>
<%@ Import Namespace="System.Xml.Xsl"%>
<%@ Import Namespace="System.Xml.XPath"%>
<%@ Import Namespace="System.Configuration" %>
<%@ Import Namespace="System.Security.Cryptography" %>
<%@ Import Namespace="System.Security.Cryptography.X509Certificates" %>
<%@ Import Namespace="System.Web" %>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link type="text/css" rel="stylesheet" href="/main.css"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title id="title" runat=server></title></head>
<body>

<%
    usrUtil usru = new usrUtil(Page);
    sqlUtil sqlu = new sqlUtil();

    if ((usru.authlevel & 8) != 8)
        return;
    
    XmlDocument doc = sqlu.XDocFromSP("exec adm_match_password");

    XPathNavigator nav = doc.CreateNavigator();
    XPathNodeIterator Iterator = nav.Select("/users/user");

    while (Iterator.MoveNext())
    {
        if (gpUtil.md5(Iterator.Current.GetAttribute("plainpw", "")) != Iterator.Current.GetAttribute("dbhashedpw", ""))
        {
            Response.Write("<b>" + Iterator.Current.GetAttribute("nick", "") + "</b>");
            Response.Write("<br/>");
            Response.Write("dammela pw hashed:" + gpUtil.md5(Iterator.Current.GetAttribute("plainpw", "")));
            Response.Write("<br/>");
            Response.Write("dammela pw hashed:" + Iterator.Current.GetAttribute("dbhashedpw", ""));
            Response.Write("<p/>");
            if (Request.QueryString.Get("fixit") != null && Request.QueryString.Get("fixit") == "1")
                sqlu.executeSP("exec adm_match_password @userid='" + Iterator.Current.GetAttribute("userid", "")
                    + "', @dotnethashedpw='" + gpUtil.md5(Iterator.Current.GetAttribute("plainpw", "")) + "'");
        }
    }

%>

</body>
</html>
